var Exam = { 
	etype:{1:"阶段性作业",2:"结业考试"},
	num:{0:"一、",1:"二、",2:"三、",3:"四、",4:"五、",5:"六、",6:"七、"},
	exaInit: function(cid){
		var listFn = function(cid){
			$ajax({
				url:"/examine/listPaper",
				data:{ 
					cid: cid
				},
				success: function(res) {
					var data = res.result.results;
					var html = "";
					if(data.length == 0) {
						$("#examList").addClass("ub uh100");
						html += '<div class="ub-f1 ub ub-pc upt_percent15"> '+
	            					'<div class="ub ub-ver">'+
	                					'<div class="im_no_exam ub-img6 uh14"></div>'+
	                					'<div class="c_hui">您还没有参加过结业考试！</div>'+
	            					'</div>'+
	        					'</div>';
					}else {
						$("#examList").removeClass("ub uh100");
						html = 	'<div class="ub ub-f1 ub-img2 im_tab_bg">' + 
					        	'	<div class="ub-f1 ut-s c_tip ump5 upl_percent5" style="width: 50%;">  课程名称</div>' + 
					        	'	<div class="ub-f2 ut-s ump5 c_tip"  style="width: 25%;">考试时间</div>' + 
					        	'	<div class="ub-f1 ut-s ump5 c_tip tx-c"  style="width: 15%;">分数</div>' + 
					        	'</div>';
						for (var i = 0; i < data.length; i ++){ 
							var score = data[i].score;
							html += '<div class="ub ub-f1 upp4 ubb b_gra c-wh" ontouchstart="zy_touch(\'btn-act\')" onclick="Exam.jumpExam(\'' + data[i]._id + '\', \'' + data[i].course.name + '\');">' + 
						        	'	<div class="ub-f1 ut-s ump5 upl_percent5 c_gra" style="width: 48%;">' + data[i].course.name + '</div>' + 
						        	'	<div class="ub-f2 ut-s ump5 c_gra"  style="width: 27%;">' + (new Date(data[i].create)).pattern("yyyy-MM-dd") + '</div>'; 
						    if(score >= 60){
						    	html += '	<div class="ub-f1 ut-s ump5 c_hege tx-c"  style="width: 15%;">' + score + '</div>';
						    }else{
						    	html += '	<div class="ub-f1 ut-s ump5 c_list tx-c"  style="width: 15%;">' + score + '</div>';
						    }
						    html += '</div>';
						}
					}
					$("#examList").html(html);
				}
			});	
		};
		listFn(cid);
	},
	errInit: function(cid){
		var listFn = function(cid){
			$ajax({
				url: "/errSet/list",
				data: { 
					cid: cid
				},
				success: function(res){
					var res = res.result.results;
	                var html = "";
	                SetLS("errset",res);
	                if(res.length == 0) {
	                    $("#errorSetList").addClass("ub uh100");
	                    html += '<div class="ub-f1 ub ub-pc upt_percent15"> '+
	                                '<div class="ub ub-ver">'+
	                                    '<div class="im_no_errorset ub-img6 uh14"></div>'+
	                                    '<div class="c_hui">我们还未记录到您做错过试题！</div>'+
	                                '</div>'+
	                            '</div>';
	                }else {
	                    $("#errorSetList").removeClass("ub uh100");
	                    for (var i = 0; i < res.length; i ++){
	                        html += '<div data-id="' + res[i]._id + '" class="up1_0 upl_percent4 ubb b_gra ut-s c-wh" ontouchstart="zy_touch()" onclick="Exam.examErrJump(\'' + i + '\', \'' + res[i].Content + '\');"><img src="img/talk_ctn_right.png" class="uw1 uh1"> ' + (i + 1) + '.' + res[i].Content + '</div>';
	                    }   
	                }
	                $("#errorSetList").html(html);
				}
			});
		};
		listFn(cid);
	},
	examFn: function(id,value,flag){
		if (value == "exam"){
		    var cid = "";
		    if(!flag){
		        cid = id;
		    }
			$ajax({
				url:"/examine/listPaper",
				data:{ 
					cid: cid
				},
				success: function(res) {
					var data = res.result.results;
					var html = "";
					if(data.length == 0) {
						$("#examList").addClass("ub uh100");
						html += '<div class="ub-f1 ub ub-pc upt_percent15"> '+
                					'<div class="ub ub-ver">'+
                    					'<div class="im_no_exam ub-img6 uh14"></div>'+
                    					'<div class="c_hui">您还没有参加过结业考试！</div>'+
                					'</div>'+
            					'</div>';
					}else {
						$("#examList").removeClass("ub uh100");
						html = 	'<div class="ub ub-f1 ub-img2 im_tab_bg">' + 
					        	'	<div class="ub-f1 ut-s c_tip ump5 upl_percent5" style="width: 50%;">  课程名称</div>' + 
					        	'	<div class="ub-f2 ut-s ump5 c_tip"  style="width: 25%;">考试时间</div>' + 
					        	'	<div class="ub-f1 ut-s ump5 c_tip tx-c"  style="width: 15%;">分数</div>' + 
					        	'</div>';
						for (var i = 0; i < data.length; i ++){ 
							var score = data[i].score;
							html += '<div class="ub ub-f1 upp4 ubb b_gra c-wh" ontouchstart="zy_touch(\'btn-act\')" onclick="Exam.jumpExam(\'' + data[i]._id + '\', \'' + data[i].course.name + '\');">' + 
						        	'	<div class="ub-f1 ut-s ump5 upl_percent5 c_gra" style="width: 48%;">' + data[i].course.name + '</div>' + 
						        	'	<div class="ub-f2 ut-s ump5 c_gra"  style="width: 27%;">' + (new Date(data[i].create)).pattern("yyyy-MM-dd") + '</div>'; 
						    if(score >= 60){
						    	html += '	<div class="ub-f1 ut-s ump5 c_hege tx-c"  style="width: 15%;">' + score + '</div>';
						    }else{
						    	html += '	<div class="ub-f1 ut-s ump5 c_list tx-c"  style="width: 15%;">' + score + '</div>';
						    }
						    html += '</div>';
						}
					}
					$("#examList").html(html);
				}
			});	
		}
        if (value == "errorset"){
			$ajax({
				url: "/errSet/list",
				data: { 
					cid: id
				},
				success: function(res){
					var res = res.result.results;
                    var html = "";
                    SetLS("errset",res);
                    if(res.length == 0) {
                        $("#errorSetList").addClass("ub uh100");
                        html += '<div class="ub-f1 ub ub-pc upt_percent15"> '+
                                    '<div class="ub ub-ver">'+
                                        '<div class="im_no_errorset ub-img6 uh14"></div>'+
                                        '<div class="c_hui">我们还未记录到您做错过试题！</div>'+
                                    '</div>'+
                                '</div>';
                    }else {
                        $("#errorSetList").removeClass("ub uh100");
                        for (var i = 0; i < res.length; i ++){
                            html += '<div data-id="' + res[i]._id + '" class="up1_0 upl_percent4 ubb b_gra ut-s c-wh" ontouchstart="zy_touch()" onclick="Exam.examErrJump(\'' + i + '\', \'' + res[i].Content + '\');"><img src="img/talk_ctn_right.png" class="uw1 uh1"> ' + (i + 1) + '.' + res[i].Content + '</div>';
                        }   
                    }
                    $("#errorSetList").html(html);
				}
			});
		}	
	},	
	jumpExam: function(examId, courseName){ 
		SetLS("examId",examId);
		SetLS("exam_detail_title", courseName);
		OpenNewWin("exam_detail");
	},
	examDetailInit: function(){
		$ajax({
			url : "/examine/detailPaper",
			data: {
				_id: GetLS("examId")
			},
			success: function(res){
				var html = "";
				$("#record_bg").text(res.result.score);
				$("#fen").addClass("ub").text("分");
				if(res.result.score >= 60)
					$("#record_bg").addClass('c_hege');
				else
					$("#record_bg").addClass('list');

				var res = res.result.questions;
				var SINGLE_CHOICE = '',MULTIPLE_CHOICE = '',JUDGE = '',FILL = '',SUBJECTIVE = '',LIGATURE = '',SORT = '';
				var SINGLE_NUM = 0,MULTIPLE_NUM = 0,JUDGE_NUM = 0,FILL_NUM = 0,SUBJECTIVE_NUM = 0,LIGATURE_NUM = 0,SORT_NUM = 0;
				for (var i = 0; i < res.length; i ++){
					if (res[i].QuestionType == EXAMTYPE.SINGLE_CHOICE){
						SINGLE_NUM ++;
						SINGLE_CHOICE += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i]._id + '">' + 
                            				'<h3>'  +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></h3>' + 
                            				'<ul>' + 
                                			'<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + SINGLE_NUM + "、" + res[i].Content + '</h5>';
	                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                    	var isOrNotChecked = "";
	                    	var styl = "";
	                        if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        	isOrNotChecked = "checked";
	                        	styl = "style='background-color: rgb(221, 235, 249);'";
	                        }
	                    	SINGLE_CHOICE += '<li '+styl+'>' + 
	                                    		'<label><input type="radio" class="uw2 uh2" '+isOrNotChecked+' name="' + res[i]._id + '" id="' + res[i].QuestionOptionList[j].Id + '"><font>' + res[i].QuestionOptionList[j].Content + '</font></label>' + 
	                                		 '</li>';
	                    }      		
                   		 SINGLE_CHOICE +=  '</ul>' + 
                    						'<div class="issbor"></div>' + 
                    						'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div>';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                    if (res[i].QuestionOptionList[j].IfRightAnswer){
		                        SINGLE_CHOICE += '<div class="c_blk ub-f1">' + res[i].QuestionOptionList[j].Content + '</div></div>';
		                    }          		
		                }
		             	SINGLE_CHOICE +='<div class="issbor"></div>' + 	
                        				'</div>'+
		             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res[i].Tip) + '</div></div>' +     
		             					'<div class="issbor"></div>' + 	
                        				'</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.MULTIPLE_CHOICE){
						MULTIPLE_NUM ++;
						MULTIPLE_CHOICE += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i]._id + '">' + 
		                            '<h3>' +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></h3>' + 
		                            '<ul>' + 
		                                '<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + MULTIPLE_NUM + "、"  + res[i].Content + '</h5>';
	                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                    	var isOrNotChecked = "";
	                    	var styl = "";
	                        for (var k = 0; k < res[i].stuAnswer.length; k ++){     
		                        if (res[i].stuAnswer[k] == res[i].QuestionOptionList[j].Id) {
		                        	isOrNotChecked = "checked";
		                        	styl = "style='background-color: rgb(221, 235, 249);'";
		                        }
	                        }
	                    	MULTIPLE_CHOICE += '<li '+styl+'>' + 
	                                    '<label><input type="checkbox" class="uw2 uh2" '+isOrNotChecked+' name="' + res[i]._id + '" id="' + res[i].QuestionOptionList[j].Id + '"><font>' + res[i].QuestionOptionList[j].Content + '</font></label>' + 
	                                '</li>';
	                    }      
                    	MULTIPLE_CHOICE +=  '</ul>' + 
                    		'<div class="issbor"></div>' + 	
                    		'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div><div class="ub ub-ver">';
                        for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                    if (res[i].QuestionOptionList[j].IfRightAnswer){
		                        MULTIPLE_CHOICE += '<div class="c_blk ub-f1">' + res[i].QuestionOptionList[j].Content + '</div>';
		                    }          		
		                }
		                MULTIPLE_CHOICE +='</div>'+
		                					'</div>'+
		                					'<div class="issbor"></div>' + 	
                        				'</div>'+
		             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res[i].Tip) + '</div></div>' +     
		             					'<div class="issbor"></div>' + 	
                        				'</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.JUDGE){
						JUDGE_NUM ++;
						JUDGE += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i]._id + '">' + 
		                            '<h3>' +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></h3>' + 
		                            '<ul>' + 
		                                '<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + JUDGE_NUM + "、" + res[i].Content + '</h5>';
		                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
		                    	var isOrNotChecked = "";
		                    	var styl = "";
	                        	if (res[i].stuAnswer[0] == res[i].QuestionOptionList[j].Id) {
	                        		isOrNotChecked = "checked";
	                        		styl = "style='background-color: rgb(221, 235, 249);'";
	                        	}
		                    	JUDGE += '<li '+styl+'>' + 
		                                    '<label><input type="radio" class="uw2 uh2" '+isOrNotChecked+' name="' + res[i]._id + '" id="' + res[i].QuestionOptionList[j].Id + '"><font>' + res[i].QuestionOptionList[j].Content + '</font></label>' + 
		                                '</li>';
		                    }      
		                    JUDGE +=  '</ul>' + 
		                    		'<div class="issbor"></div>' + 	
		                    		'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div>';
		                        		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
				                        	if (res[i].QuestionOptionList[j].IfRightAnswer){
				                        		JUDGE += '<div class="c_blk ub-f1">' + res[i].QuestionOptionList[j].Content + '</div></div>';
				                        	}          		
				                        }
				                JUDGE +='<div class="issbor"></div>' + 	
                        				'</div>'+
		             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res[i].Tip) + '</div></div>' +     
		             					'<div class="issbor"></div>' + 	
                        				'</div>';      
					}
					else if (res[i].QuestionType == EXAMTYPE.LIGATURE){
						LIGATURE_NUM ++;
						LIGATURE += '<div class="cnt uptb_p5" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i]._id + '">' + 
	                                '<h3>' + (i + 1) + "." +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></h3>' + 
	                                    '<h5 style="margin: 1em 0em 1em 9%;position:relative;">' + res[i].Content + '</h5>' + 
	                                	'<div class="tipEvt c-wh c_red" style="padding-left:1em;background-color: #FFF;margin:0.5em;font-weight: normal;">点击下面内容加载连线 : </div>' + 	                                    
	                        			'<ul class="tipEvt c-wh" style="background-color: #FFF;">' + 
	                        			'<div class="matchByLineBox mlBoxCol">';
	                        			var left = '<div class="matchSide matchSideQue">';
	                        			var right = '<div class="matchSide matchSideAns">';
	                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
			                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
			                            		var ans = '';
		                        				for (var k = 0; k < res[i].stuAnswer.length; k ++){
		                        					if (res[i].QuestionOptionList[j].Id == res[i].stuAnswer[k]){
		                        						ans = res[i].stuAnswer[k+1];
		                        					}
		                        				}
			                            		left += '<div class="matchOne c_blk tx-c" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '" ans="' + ans + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
			                            		right += '<div class="matchOne c_blk tx-c" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
			                            	}
			                            }
			                            left += '</div>';
			                            right += '</div>';
	                       			LIGATURE += left + right + 
	                       			'</ul>' + 
	                            '</div>';
		                        LIGATURE += '<div class="tipEvt c-wh c_red" style="padding-left:1em;background-color: #FFF;margin:0.5em;font-weight: normal;">点击下面内容查看正确答案 : </div>' + 
		                        		'<ul class="tipEvt c-wh" style="background-color: #FFF;">' + 
		                        			'<div class="matchByLineBox mlBoxCol">';
		                        			var left = '<div class="matchSide matchSideQue">';
		                        			var right = '<div class="matchSide matchSideAns">';
		                        			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
				                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
				                            		for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
				                            			if (res[i].QuestionOptionList[l].OrderNum == res[i].QuestionOptionList[j].OrderNum+1)
				                            				var ans = res[i].QuestionOptionList[l].Id;
				                            		}
				                            		left += '<div class="matchOne c_blk tx-c" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
				                            	}
				                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
				                            		right += '<div class="matchOne c_blk tx-c" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
				                            	}
				                            }
				                            left += '</div>';
				                            right += '</div>';
		                       			LIGATURE += left + right + 
		                       			'</ul>';   
		                       	LIGATURE +=	'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res[i].Tip) + '</div></div>' +     
		             					'<div class="issbor"></div>' + 	
                        				'</div>';
		                        		   
					}
					else if (res[i].QuestionType == EXAMTYPE.SORT){
						SORT_NUM ++;
						//冒泡排序,用于正确答案
						var temp = 0;
						var targetArr = res[i].QuestionOptionList;
			            for(var k = 0;k<targetArr.length;k++){
			                for(var j = k;j<targetArr.length;j++){
			                    if(targetArr[k].OrderNum>targetArr[j].OrderNum){
			                        temp = targetArr[k];
			                        targetArr[k] = targetArr[j];
			                        targetArr[j] = temp;
			                     }
			                 }
			            }
						SORT += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i]._id + '">' + 
		                            '<h3>' +  res[i].QtypeString + '<span class="score" data-score="' + res[i].QScore + '">' + res[i].QScore + '分</span></h3>' + 
		                            '<h5 style="margin: 1em 0em 1em 9%;position:relative;"><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + SORT_NUM + "、" + res[i].Content + '</h5>' + 
		                            '<div class="custom_order" id="custom_order">' + 
				                    '    <div class="custom_sort_form">' + 
				                    '        <ul class="sort_div" id="sort_div" style="padding:1em;">';
		                    for (var j = 0; j < res[i].stuAnswer.length; j ++){
		                    	for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
		                    		if (res[i].stuAnswer[j] == res[i].QuestionOptionList[l].Id){
				                    	SORT += '<li class="ub" id="' + res[i].QuestionOptionList[l].Id + '" data-ordernum="' + res[i].QuestionOptionList[l].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
				                                '    <div class="v_middle ub-f1" id="' + res[i].QuestionOptionList[l].Id + '_h" style="cursor: move;">' + res[i].QuestionOptionList[l].Content + '</div>' + 
				                                '	<div class="upp5 ub ub-ac" ontouchstart="zy_touch" onclick="Course.topMove()">上移</div>' + 
				                                '	<div class="upp5 ub ub-ac" ontouchstart="zy_touch" onclick="Course.bottomMove()">下移</div>' + 
				                                '</li>';
				                    }
		                    	}
		                    }      
			                    SORT += '	 </ul>' + 
			                    		'<div class="issbor"></div>' + 	
					                    '<div class="tipEvt c_red" style="padding-left:1em;background-color: #FFF;margin:0.5em;">正确答案 : </div>';
					                		for (var j = 0; j < targetArr.length; j ++){
					                        	SORT += '<li class="tipEvt" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;background-color: #FFF;">' + 
						                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
						                                '</li>';
				                        	}
			                    	SORT +=	'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res[i].Tip) + '</div></div>' +     
		             					'<div class="issbor"></div>' + 	
                        				'</div>'+ 
				                    '</div>' + 
				                '</div>';            
					}
				}
				var num = 0;
				SINGLE_CHOICE = SINGLE_NUM>0?('<h3>' + Exam.num[num] + '单选题</h3>' + SINGLE_CHOICE):"";num = SINGLE_NUM>0?num+1:num;
				MULTIPLE_CHOICE = MULTIPLE_NUM>0?'<h3>' + Exam.num[num] + '多选题</h3>' + MULTIPLE_CHOICE:"";num = MULTIPLE_NUM>0?num+1:num;
				JUDGE = JUDGE_NUM>0?'<h3>' + Exam.num[num] + '判断题</h3>' + JUDGE:"";num = JUDGE_NUM>0?num+1:num;
				FILL = FILL_NUM>0?'<h3>' + Exam.num[num] + '填空题</h3>' + FILL:"";num = FILL_NUM>0?num+1:num;
				SUBJECTIVE = SUBJECTIVE_NUM>0?'<h3>' + Exam.num[num] + '问答题</h3>' + SUBJECTIVE:"";num = SUBJECTIVE_NUM>0?num+1:num;
				LIGATURE = LIGATURE_NUM>0?'<h3>' + Exam.num[num] + '匹配题</h3>' + LIGATURE:"";num = LIGATURE_NUM>0?num+1:num;
				SORT = SORT_NUM>0?'<h3>' + Exam.num[num] + '排序题</h3>' + SORT:"";

				var html = SINGLE_CHOICE + MULTIPLE_CHOICE + JUDGE + FILL + SUBJECTIVE + LIGATURE + SORT;
				$("#detailExam").html(html);	
				// 初始化连线canvas
				var mblBoxs=$(".matchByLineBox");
				mblArr=[];//全局 存储所有mbl实例
				mblBoxs.each(function(x){
					var mbl=new MatchByLine(mblBoxs.eq(x));
					mbl.init();
					mblArr.push(mbl);
				});
				// 初始化拖动排序
				initDrag();
			}
		});	
	},
	examErrJump: function(i, content){ 
		SetLS("errorSetCName",content);
		SetLS("errsetDetail", GetLS("errset")[i]);
		OpenNewWin("exam_errorset_detail");
	},
	examErrorDetailInit: function(){ 
		var res = GetLS("errsetDetail");
		console.log(res);
		var html = "";
		if (res.QuestionType == EXAMTYPE.SINGLE_CHOICE){
				html += '<div class="cnt" data-questiontype="' + res.QuestionType + '" data-id="' + res._id + '">' + 
                    				'<h3>'  +  res.QtypeString + '<span class="score" data-score="' + res.QScore + '">' + res.QScore + '分</span></h3>' + 
                    				'<ul>' + 
                        			'<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + res.Content + '</h5>';
                for (var j = 0; j < res.QuestionOptionList.length; j ++){
                	var isOrNotChecked = "";
                	var styl = "";
                    if (res.stuAnswer[0] == res.QuestionOptionList[j].Id) {
                    	isOrNotChecked = "checked";
                    	styl = "style='background-color: rgb(221, 235, 249);'";
                    }
                	html += '<li '+styl+'>' + 
                                		'<label><input type="radio" class="uw2 uh2" '+isOrNotChecked+' name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '"><font>' + res.QuestionOptionList[j].Content + '</font></label>' + 
                            		 '</li>';
                }      		
           		 html +=  '</ul>' + 
            						'<div class="issbor"></div>' + 
            						'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div>';
                for (var j = 0; j < res.QuestionOptionList.length; j ++){
                    if (res.QuestionOptionList[j].IfRightAnswer){
                        html += '<div class="c_blk ub-f1">' + res.QuestionOptionList[j].Content + '</div></div>';
                    }          		
                }
             	html +='<div class="issbor"></div>' + 	
                				'</div>'+
             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res.Tip) + '</div></div>' +     
             					'<div class="issbor"></div>' + 	
                				'</div>';       
			}
			else if (res.QuestionType == EXAMTYPE.MULTIPLE_CHOICE){
				html += '<div class="cnt" data-questiontype="' + res.QuestionType + '" data-id="' + res._id + '">' + 
                            '<h3>' +  res.QtypeString + '<span class="score" data-score="' + res.QScore + '">' + res.QScore + '分</span></h3>' + 
                            '<ul>' + 
                                '<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">'+ res.Content + '</h5>';
                for (var j = 0; j < res.QuestionOptionList.length; j ++){
                	var isOrNotChecked = "";
                	var styl = "";
                    for (var k = 0; k < res.stuAnswer.length; k ++){     
                        if (res.stuAnswer[k] == res.QuestionOptionList[j].Id) {
                        	isOrNotChecked = "checked";
                        	styl = "style='background-color: rgb(221, 235, 249);'";
                        }
                    }
                	html += '<li '+styl+'>' + 
                                '<label><input type="checkbox" class="uw2 uh2" '+isOrNotChecked+' name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '"><font>' + res.QuestionOptionList[j].Content + '</font></label>' + 
                            '</li>';
                }      
            	html +=  '</ul>' + 
            		'<div class="issbor"></div>' + 	
            		'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div><div class="ub ub-ver">';
                for (var j = 0; j < res.QuestionOptionList.length; j ++){
                    if (res.QuestionOptionList[j].IfRightAnswer){
                        html += '<div class="c_blk ub-f1">' + res.QuestionOptionList[j].Content + '</div>';
                    }          		
                }
                html +='</div>'+
                		'</div>'+
                		'<div class="issbor"></div>' + 	
                				'</div>'+
             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res.Tip) + '</div></div>' +     
             					'<div class="issbor"></div>' + 	
                				'</div>';     
			}
			else if (res.QuestionType == EXAMTYPE.JUDGE){
				html += '<div class="cnt" data-questiontype="' + res.QuestionType + '" data-id="' + res._id + '">' + 
                            '<h3>' +  res.QtypeString + '<span class="score" data-score="' + res.QScore + '">' + res.QScore + '分</span></h3>' + 
                            '<ul>' + 
                                '<h5><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + res.Content + '</h5>';
                    for (var j = 0; j < res.QuestionOptionList.length; j ++){
                    	var isOrNotChecked = "";
                    	var styl = "";
                    	if (res.stuAnswer[0] == res.QuestionOptionList[j].Id) {
                    		isOrNotChecked = "checked";
                    		styl = "style='background-color: rgb(221, 235, 249);'";
                    	}
                    	html += '<li '+styl+'>' + 
                                    '<label><input type="radio" class="uw2 uh2" '+isOrNotChecked+' name="' + res.QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res.QuestionOptionList[j].Id + '"><font>' + res.QuestionOptionList[j].Content + '</font></label>' + 
                                '</li>';
                    }      
                    html +=  '</ul>' + 
                    		'<div class="issbor"></div>' + 	
                    		'<div class="ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#FFF;">正确答案 : </div>';
                        		for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                        	if (res.QuestionOptionList[j].IfRightAnswer){
		                        		html += '<div class="c_blk ub-f1">' + res.QuestionOptionList[j].Content + '</div></div>';
		                        	}          		
		                        }
		                html +='<div class="issbor"></div>' + 	
                				'</div>'+
             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res.Tip) + '</div></div>' +     
             					'<div class="issbor"></div>' + 	
                				'</div>';      
			}
			else if (res.QuestionType == EXAMTYPE.LIGATURE){
				html += '<div class="cnt uptb_p5" data-questiontype="' + res.QuestionType + '" data-id="' + res._id + '">' + 
                            '<h3>' +  res.QtypeString + '<span class="score" data-score="' + res.QScore + '">' + res.QScore + '分</span></h3>' + 
                                '<h5 style="padding-left: 2.5em;">' + res.Content + '</h5>' + 
                    			'<ul class="tipEvt c-wh" style="background-color: #FFF;padding:0;">' + 
                    			'<div class="matchByLineBox mlBoxCol" style="width:90%;">';
                    			var left = '<div class="matchSide matchSideQue">';
                    			var right = '<div class="matchSide matchSideAns">';
                    			for (var j = 0; j < res.QuestionOptionList.length; j ++){
	                            	if (res.QuestionOptionList[j].OrderNum%2 == 1){
	                            		var ans = '';
                        				for (var k = 0; k < res.stuAnswer.length; k ++){
                        					if (res.QuestionOptionList[j].Id == res.stuAnswer[k]){
                        						ans = res.stuAnswer[k+1];
                        					}
                        				}
	                            		left += '<div class="matchOne c_blk tx-c" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '" ans="' + ans + '">' + res.QuestionOptionList[j].Content + '</div>';
	                            	}
	                            	else if (res.QuestionOptionList[j].OrderNum%2 == 0){
	                            		right += '<div class="matchOne c_blk tx-c" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '">' + res.QuestionOptionList[j].Content + '</div>';
	                            	}
	                            }
	                            left += '</div>';
	                            right += '</div>';
                   			html += left + right + 
                   			'</ul>' + 
                        '</div>';
                        html += '<div class="tipEvt c-wh c_red" style="padding-left:1em;background-color: #FFF;margin:0.5em;font-weight: normal;">点击下面内容查看正确答案 : </div>' + 
                        		'<ul class="tipEvt c-wh" style="background-color: #FFF;padding:0;">' + 
                        			'<div class="matchByLineBox mlBoxCol" style="width:90%;">';
                        			var left = '<div class="matchSide matchSideQue">';
                        			var right = '<div class="matchSide matchSideAns">';
                        			for (var j = 0; j < res.QuestionOptionList.length; j ++){
		                            	if (res.QuestionOptionList[j].OrderNum%2 == 1){
		                            		for (var l = 0; l < res.QuestionOptionList.length; l ++){
		                            			if (res.QuestionOptionList[l].OrderNum == res.QuestionOptionList[j].OrderNum+1)
		                            				var ans = res.QuestionOptionList[l].Id;
		                            		}
		                            		left += '<div class="matchOne c_blk tx-c" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            	else if (res.QuestionOptionList[j].OrderNum%2 == 0){
		                            		right += '<div class="matchOne c_blk tx-c" data-ordernum="' + res.QuestionOptionList[j].OrderNum + '" id="' + res.QuestionOptionList[j].Id + '0">' + res.QuestionOptionList[j].Content + '</div>';
		                            	}
		                            }
		                            left += '</div>';
		                            right += '</div>';
                       			html += left + right + 
                       			'</ul>';   
                       	html +='<div class="issbor"></div>' + 	
                				'</div>'+
             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res.Tip) + '</div></div>' +     
             					'<div class="issbor"></div>' + 	
                				'</div>';  
			}
			else if (res.QuestionType == EXAMTYPE.SORT){
				//冒泡排序,用于正确答案
				var temp = 0;
				var targetArr = res.QuestionOptionList;
	            for(var k = 0;k<targetArr.length;k++){
	                for(var j = k;j<targetArr.length;j++){
	                    if(targetArr[k].OrderNum>targetArr[j].OrderNum){
	                        temp = targetArr[k];
	                        targetArr[k] = targetArr[j];
	                        targetArr[j] = temp;
	                     }
	                 }
	            }
				html += '<div class="cnt" data-questiontype="' + res.QuestionType + '" data-id="' + res._id + '">' + 
                            '<h3>' +  res.QtypeString + '<span class="score" data-score="' + res.QScore + '">' + res.QScore + '分</span></h3>' + 
                            '<h5 style="margin: 1em 0em 1em 9%;position:relative;"><img src="img/ico_right.png" class="ico_wrimg right"><img src="img/ico_err.png" class="ico_wrimg wrong">' + res.Content + '</h5>' + 
                            '<div class="custom_order" id="custom_order">' + 
		                    '    <div class="custom_sort_form">' + 
		                    '        <ul class="sort_div" id="sort_div" style="padding:1em;">';
                    for (var j = 0; j < res.stuAnswer.length; j ++){
                    	for (var l = 0; l < res.QuestionOptionList.length; l ++){
                    		if (res.stuAnswer[j] == res.QuestionOptionList[l].Id){
		                    	html += '<li class="ub" id="' + res.QuestionOptionList[l].Id + '" data-ordernum="' + res.QuestionOptionList[l].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
		                                '    <div class="v_middle ub-f1" id="' + res.QuestionOptionList[l].Id + '_h" style="cursor: move;">' + res.QuestionOptionList[l].Content + '</div>' + 
		                                '	<div class="upp5 ub ub-ac" ontouchstart="zy_touch" onclick="Course.topMove()">上移</div>' + 
		                                '	<div class="upp5 ub ub-ac" ontouchstart="zy_touch" onclick="Course.bottomMove()">下移</div>' + 
		                                '</li>';
		                    }
                    	}
                    }      
	                    html += '	 </ul>' + 
	                    		'<div class="issbor"></div>' + 	
			                    '<div class="tipEvt c_red" style="padding-left:1em;background-color: #FFF;margin:0.5em;">正确答案 : </div>';
			                		for (var j = 0; j < targetArr.length; j ++){
			                        	html += '<li class="tipEvt" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;background-color: #FFF;">' + 
				                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
				                                '</li>';
		                        	}
	                    	html +='<div class="issbor"></div>' + 	
                				'</div>'+
             						'<div class="tipEvt ub" style="padding:1em;"><div class="c_red upr_p5" style="background-color:#f5f5f5;">&nbsp;&nbsp;解析 : </div><div class="c_blk ub-f1" style="background-color:#f5f5f5;">' + (res.Tip) + '</div></div>' +     
             					'<div class="issbor"></div>' + 	
                				'</div>'+
		                    '</div>' + 
		                '</div>';            
			}
		$("#errorDetail").html(html);
		// 初始化连线canvas
		var mblBoxs=$(".matchByLineBox");
		mblArr=[];//全局 存储所有mbl实例
		mblBoxs.each(function(x){
			var mbl=new MatchByLine(mblBoxs.eq(x));
			mbl.init();
			mblArr.push(mbl);
		});
		if (res.QuestionType == EXAMTYPE.LIGATURE){
			for (var k = 0; k < res.stuAnswer.length/2; k ++){     
            	addOneMatchLineAns({"id": res.stuAnswer[2*k],"answer" : res.stuAnswer[2*k+1]});
        	}
		}
		// 初始化拖动排序
		initDrag();
	}
}